package com.chainyoung.component_tmtrade.ui.mvp.model;


import com.chainyoung.common.appcommon.entity.CommonList;
import com.chainyoung.common.appcommon.entity.UploadFile;
import com.chainyoung.common.di.scope.ActivityScope;
import com.chainyoung.common.integration.IRepositoryManager;
import com.chainyoung.common.mvp.BaseModel;
import com.chainyoung.common.utils.RxUtils;
import com.chainyoung.component_tmtrade.api.TradeService;
import com.chainyoung.component_tmtrade.bean.FiatOrder;
import com.chainyoung.component_tmtrade.bean.OrderDetail;
import com.chainyoung.component_tmtrade.ui.mvp.contract.TradeFiatCurrencyOrderContract;
import com.chainyoung.component_tmtrade.ui.mvp.contract.TradeFiatCurrencyOrderDetailContract;

import java.util.TreeMap;

import javax.inject.Inject;

import io.reactivex.Flowable;
import okhttp3.RequestBody;

@ActivityScope
public class TradeFiatCurrencyOrderDetailModel extends BaseModel implements TradeFiatCurrencyOrderDetailContract.Model {

    @Inject
    TradeFiatCurrencyOrderDetailModel(IRepositoryManager repositoryManager) {
        super(repositoryManager);

    }


    @Override
    public Flowable<OrderDetail> getOrderDetail(TreeMap<String, Object> map) {
        return mRepositoryManager.obtainRetrofitService(TradeService.class)
                .getOrderDetail(map)
                .compose(RxUtils.<OrderDetail>handleResult());
    }

    @Override
    public Flowable<String> cancelOrder(TreeMap<String, Object> map) {
        return mRepositoryManager.obtainRetrofitService(TradeService.class)
                .cancelOrder(map)
                .compose(RxUtils.<String>handleResult());
    }

    @Override
    public Flowable<String> confirmPayOrder(TreeMap<String, Object> map) {
        return mRepositoryManager.obtainRetrofitService(TradeService.class)
                .confirmPayed(map)
                .compose(RxUtils.<String>handleResult());
    }

    @Override
    public Flowable<String> confirmRelease(TreeMap<String, Object> map) {
        return mRepositoryManager.obtainRetrofitService(TradeService.class)
                .confirmRelease(map)
                .compose(RxUtils.<String>handleResult());
    }

    @Override
    public Flowable<UploadFile> upLoadPayImg(RequestBody params) {
        return mRepositoryManager.obtainRetrofitService(TradeService.class)
                .upLoadPayImg(params)
                .compose(RxUtils.<UploadFile>handleResult());
    }


}
